package com.ruoyi.order.station.transform;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.order.bo.ProductHeader;
import com.ruoyi.order.domain.MesDetectNode;
import com.ruoyi.order.proxy.factory.req.FactoryHeader;
import com.ruoyi.order.proxy.factory.req.ProcessDataRequest;
import com.ruoyi.order.station.operate.cmd.*;
import com.ruoyi.order.station.operate.value.*;
import com.ruoyi.order.station.request.DB5410PLC;
import com.ruoyi.order.station.request.ProcessRequest;
import com.ruoyi.order.station.response.DB5410Server;
import com.ruoyi.order.station.response.DB5439Server;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

public class DBTrans {
    /**
     * 获取PLC数据后转换为PLC server部分
     * @param db5410PLC
     * @return
     */
    public static DB5410Server getDB5410Server(DB5410PLC db5410PLC){
        DB5410Server db5410Server = new DB5410Server();
        db5410Server.setTelegramNumber(db5410PLC.getTelegramNumber());
        db5410Server.setLineNo(db5410PLC.getLineNo());
        db5410Server.setStationNo(db5410PLC.getStationNo());
        db5410Server.setRouteList(db5410PLC.getRouteList());
        db5410Server.setPartIdentifier(db5410PLC.getPartIdentifier());
        db5410Server.setStationindex(db5410PLC.getStationindex());
        db5410Server.setTypeNo(db5410PLC.getTypeNo());
        byte[] data = new byte[10];
        data[0] = 1;
        db5410Server.setReturnCode(data);
        return db5410Server;
    }

    public static DB5439Server getDB5439Server(ProcessRequest processRequest){
        DB5439Server db5439Server = new DB5439Server();
        db5439Server.setTelegramNumber(processRequest.getTelegramNumber());
        db5439Server.setLineNo(processRequest.getLineNo());
        db5439Server.setStationNo(processRequest.getStationNo());
        db5439Server.setStationindex(processRequest.getStationindex());
        db5439Server.setFinishIO(1);
        db5439Server.setReturnCode(1);
        return db5439Server;
    }
    /**
     * 获取PLC报文头数据后转换为可以保存入表的(mes_product_node_result.test_header)
     * @param processRequest
     * @return
     */
    public static ProductHeader getProductHeader(ProcessRequest processRequest){
        ProductHeader productHeader = new ProductHeader();
        productHeader.setTelegramNumber(processRequest.getTelegramNumber());
        productHeader.setLineNo(processRequest.getLineNo());
        productHeader.setStationNo(processRequest.getStationNo());
        productHeader.setStationindex(processRequest.getStationindex());
        productHeader.setWpcId(new String(processRequest.getWpcId(), StandardCharsets.UTF_8));
        productHeader.setWpcId(StringUtils.trim(productHeader.getWpcId()));
        productHeader.setTypeNo(new String(processRequest.getTypeNo(), StandardCharsets.UTF_8));
        productHeader.setTypeNo(StringUtils.trim(productHeader.getTypeNo()));
        productHeader.setPartIdentifier(new String(processRequest.getPartIdentifier(), StandardCharsets.UTF_8));
        productHeader.setPartIdentifier(StringUtils.trim(productHeader.getPartIdentifier()));
        productHeader.setProductionTime(new String(processRequest.getProductionTime(), StandardCharsets.UTF_8));
        productHeader.setResult(processRequest.getResult());
        productHeader.setNoBits(processRequest.getNoBits());
        return productHeader;
    }


    /**
     * 转换成工厂数据格式
     *
     * @param productHeader
     * @param resultId 生产记录ID
     * @param body
     * @return
     */
    public static ProcessDataRequest transformProductData(ProductHeader productHeader, Long resultId, String body) {
        ProcessDataRequest processDataRequest = new ProcessDataRequest();
        FactoryHeader header = new FactoryHeader();
        header.setResultId(resultId);
        header.setLineNo(productHeader.getLineNo());
        header.setTelegramNumber(productHeader.getTelegramNumber());
        if (productHeader.getStationNo() <10){
            header.setStationNo("OP0" + productHeader.getStationNo());
        }else{
            header.setStationNo("OP" + productHeader.getStationNo());
        }
        header.setStationIndex(productHeader.getStationindex());
        header.setWpcId(new String(productHeader.getWpcId()));
        header.setWpcId(header.getWpcId().trim());
        header.setTypeNo(new String(productHeader.getTypeNo()));
        header.setPartIdentifier(new String(productHeader.getPartIdentifier()));
        header.setPartIdentifier(header.getPartIdentifier().trim());
        header.setProductionTime(new String(productHeader.getProductionTime()));
        header.setProductionTime(header.getProductionTime().trim());
        header.setResult(productHeader.getResult());
        header.setNoBits(productHeader.getNoBits());
        processDataRequest.setHeader(header);
        processDataRequest.setBody(body);
        return processDataRequest;
    }

    /**
     *
     * @param node
     * @param cmdObject
     * @param ordObj
     * @return
     */
    public static Object transformDB5850Value(MesDetectNode node, Object cmdObject, Object ordObj){
        if (node.getMachineCode().equals("OP07")){
            OP07 op07 = (OP07) cmdObject;
            OP07Value op07Value = new OP07Value();
            op07Value.setSequencer(op07.getSequencer());
            op07Value.setAlarm(op07.getAlarm());
            op07Value.setInHomePos(op07.getInHomePos());
            op07Value.setOperationMode(op07.getOperationMode());
            op07Value.setPartIdentifier(new String(op07.getPartIdentifier(), StandardCharsets.UTF_8));
            op07Value.setTypeNo(new String(op07.getTypeNo(), StandardCharsets.UTF_8));
            op07Value.setWpcId(new String(op07.getWpcId(), StandardCharsets.UTF_8));
            op07Value.setPartIdentifier(StringUtils.trim(op07Value.getPartIdentifier()));
            op07Value.setTypeNo(StringUtils.trim(op07Value.getTypeNo()));
            op07Value.setWpcId(StringUtils.trim(op07Value.getWpcId()));

            OP07Extend op07Extend = (OP07Extend)ordObj;
            List<BaseMaterialVO> ordList = new ArrayList<>();
            BaseMaterialVO vo1 = new BaseMaterialVO();
            vo1.setName("螺丝(M3)");
            vo1.setOrdId(new String(op07Extend.getScrewOrdId(), StandardCharsets.UTF_8));
            vo1.setMaterialNo(new String(op07Extend.getScrewMaterialNo(), StandardCharsets.UTF_8));
            vo1.setBatchNo(new String(op07Extend.getScrewBatchNo(), StandardCharsets.UTF_8));
            vo1.setDate(new String(op07Extend.getScrewDate(), StandardCharsets.UTF_8));
            vo1.setQuantity(op07Extend.getScrewQuantity());
            vo1.setOrdId(StringUtils.trim(vo1.getOrdId()));
            vo1.setMaterialNo(StringUtils.trim(vo1.getMaterialNo()));
            vo1.setBatchNo(StringUtils.trim(vo1.getBatchNo()));
            vo1.setDate(StringUtils.trim(vo1.getDate()));
            ordList.add(vo1);
            BaseMaterialVO vo2 = new BaseMaterialVO();
            vo2.setName("线束");
            vo2.setOrdId(new String(op07Extend.getPencilOrdId(), StandardCharsets.UTF_8));
            vo2.setMaterialNo(new String(op07Extend.getPencilMaterialNo(), StandardCharsets.UTF_8));
            vo2.setBatchNo(new String(op07Extend.getPencilBatchNo(), StandardCharsets.UTF_8));
            vo2.setDate(new String(op07Extend.getPencilDate(), StandardCharsets.UTF_8));
            vo2.setQuantity(op07Extend.getPencilQuantity());
            vo2.setOrdId(StringUtils.trim(vo2.getOrdId()));
            vo2.setMaterialNo(StringUtils.trim(vo2.getMaterialNo()));
            vo2.setBatchNo(StringUtils.trim(vo2.getBatchNo()));
            vo2.setDate(StringUtils.trim(vo2.getDate()));
            ordList.add(vo2);
            BaseMaterialVO vo3 = new BaseMaterialVO();
            vo3.setName("线束固定座");
            vo3.setOrdId(new String(op07Extend.getPencilSeatOrdId(), StandardCharsets.UTF_8));
            vo3.setMaterialNo(new String(op07Extend.getPencilSeatMaterialNo(), StandardCharsets.UTF_8));
            vo3.setBatchNo(new String(op07Extend.getPencilSeatBatchNo(), StandardCharsets.UTF_8));
            vo3.setDate(new String(op07Extend.getPencilSeatDate(), StandardCharsets.UTF_8));
            vo3.setQuantity(op07Extend.getPencilSeatQuantity());
            vo3.setOrdId(StringUtils.trim(vo3.getOrdId()));
            vo3.setMaterialNo(StringUtils.trim(vo3.getMaterialNo()));
            vo3.setBatchNo(StringUtils.trim(vo3.getBatchNo()));
            vo3.setDate(StringUtils.trim(vo3.getDate()));
            ordList.add(vo3);
            op07Value.setOrdList(ordList);
            return op07Value;
        }
        if (node.getMachineCode().equals("OP09")){
            OP09 op09 = (OP09) cmdObject;
            OP09Value op09Value = new OP09Value();
            op09Value.setSequencer(op09.getSequencer());
            op09Value.setAlarm(op09.getAlarm());
            op09Value.setInHomePos(op09.getInHomePos());
            op09Value.setOperationMode(op09.getOperationMode());
            op09Value.setPartIdentifier(new String(op09.getPartIdentifier(), StandardCharsets.UTF_8));
            op09Value.setTypeNo(new String(op09.getTypeNo(), StandardCharsets.UTF_8));
            op09Value.setWpcId(new String(op09.getWpcId(), StandardCharsets.UTF_8));
            op09Value.setPartIdentifier(StringUtils.trim(op09Value.getPartIdentifier()));
            op09Value.setTypeNo(StringUtils.trim(op09Value.getTypeNo()));
            op09Value.setWpcId(StringUtils.trim(op09Value.getWpcId()));


            OP09Extend op09Extend = (OP09Extend)ordObj;
            List<BaseMaterialVO> ordList = new ArrayList<>();
            BaseMaterialVO vo1 = new BaseMaterialVO();
            vo1.setName("螺丝(M4)");
            vo1.setOrdId(new String(op09Extend.getScrewOrdId(), StandardCharsets.UTF_8));
            vo1.setMaterialNo(new String(op09Extend.getScrewMaterialNo(), StandardCharsets.UTF_8));
            vo1.setBatchNo(new String(op09Extend.getScrewBatchNo(), StandardCharsets.UTF_8));
            vo1.setDate(new String(op09Extend.getScrewDate(), StandardCharsets.UTF_8));
            vo1.setQuantity(op09Extend.getScrewQuantity());
            vo1.setOrdId(StringUtils.trim(vo1.getOrdId()));
            vo1.setMaterialNo(StringUtils.trim(vo1.getMaterialNo()));
            vo1.setBatchNo(StringUtils.trim(vo1.getBatchNo()));
            vo1.setDate(StringUtils.trim(vo1.getDate()));
            ordList.add(vo1);
            BaseMaterialVO vo2 = new BaseMaterialVO();
            vo2.setName("线束");
            vo2.setOrdId(new String(op09Extend.getPencilOrdId(), StandardCharsets.UTF_8));
            vo2.setMaterialNo(new String(op09Extend.getPencilMaterialNo(), StandardCharsets.UTF_8));
            vo2.setBatchNo(new String(op09Extend.getPencilBatchNo(), StandardCharsets.UTF_8));
            vo2.setDate(new String(op09Extend.getPencilDate(), StandardCharsets.UTF_8));
            vo2.setQuantity(op09Extend.getPencilQuantity());
            vo2.setOrdId(StringUtils.trim(vo2.getOrdId()));
            vo2.setMaterialNo(StringUtils.trim(vo2.getMaterialNo()));
            vo2.setBatchNo(StringUtils.trim(vo2.getBatchNo()));
            vo2.setDate(StringUtils.trim(vo2.getDate()));
            ordList.add(vo2);
            BaseMaterialVO vo3 = new BaseMaterialVO();
            vo3.setName("轧带");
            vo3.setOrdId(new String(op09Extend.getRibbonOrdId(), StandardCharsets.UTF_8));
            vo3.setMaterialNo(new String(op09Extend.getRibbonMaterialNo(), StandardCharsets.UTF_8));
            vo3.setBatchNo(new String(op09Extend.getRibbonBatchNo(), StandardCharsets.UTF_8));
            vo3.setDate(new String(op09Extend.getRibbonDate(), StandardCharsets.UTF_8));
            vo3.setQuantity(op09Extend.getRibbonQuantity());
            vo3.setOrdId(StringUtils.trim(vo3.getOrdId()));
            vo3.setMaterialNo(StringUtils.trim(vo3.getMaterialNo()));
            vo3.setBatchNo(StringUtils.trim(vo3.getBatchNo()));
            vo3.setDate(StringUtils.trim(vo3.getDate()));
            ordList.add(vo3);
            op09Value.setOrdList(ordList);
            return op09Value;
        }
        if (node.getMachineCode().equals("OP11")){
            OP11 op11 = (OP11) cmdObject;
            OP11Value op11Value = new OP11Value();
            op11Value.setSequencer(op11.getSequencer());
            op11Value.setAlarm(op11.getAlarm());
            op11Value.setInHomePos(op11.getInHomePos());
            op11Value.setOperationMode(op11.getOperationMode());
            op11Value.setPartIdentifier(new String(op11.getPartIdentifier(), StandardCharsets.UTF_8));
            op11Value.setTypeNo(new String(op11.getTypeNo(), StandardCharsets.UTF_8));
            op11Value.setWpcId(new String(op11.getWpcId(), StandardCharsets.UTF_8));
            op11Value.setPartIdentifier(StringUtils.trim(op11Value.getPartIdentifier()));
            op11Value.setTypeNo(StringUtils.trim(op11Value.getTypeNo()));
            op11Value.setWpcId(StringUtils.trim(op11Value.getWpcId()));

            OP11Extend op11Extend = (OP11Extend)ordObj;
            List<BaseMaterialVO> ordList = new ArrayList<>();
            BaseMaterialVO vo1 = new BaseMaterialVO();
            vo1.setName("螺丝(M5)");
            vo1.setOrdId(new String(op11Extend.getScrewOrdId(), StandardCharsets.UTF_8));
            vo1.setMaterialNo(new String(op11Extend.getScrewMaterialNo(), StandardCharsets.UTF_8));
            vo1.setBatchNo(new String(op11Extend.getScrewBatchNo(), StandardCharsets.UTF_8));
            vo1.setDate(new String(op11Extend.getScrewDate(), StandardCharsets.UTF_8));
            vo1.setQuantity(op11Extend.getScrewQuantity());
            vo1.setOrdId(StringUtils.trim(vo1.getOrdId()));
            vo1.setMaterialNo(StringUtils.trim(vo1.getMaterialNo()));
            vo1.setBatchNo(StringUtils.trim(vo1.getBatchNo()));
            vo1.setDate(StringUtils.trim(vo1.getDate()));
            ordList.add(vo1);

            BaseMaterialVO vo2 = new BaseMaterialVO();
            vo2.setName("密封圈");
            vo2.setOrdId(new String(op11Extend.getSealingRingOrdId(), StandardCharsets.UTF_8));
            vo2.setMaterialNo(new String(op11Extend.getSealingRingMaterialNo(), StandardCharsets.UTF_8));
            vo2.setBatchNo(new String(op11Extend.getSealingRingBatchNo(), StandardCharsets.UTF_8));
            vo2.setDate(new String(op11Extend.getSealingRingDate(), StandardCharsets.UTF_8));
            vo2.setQuantity(op11Extend.getSealingRingQuantity());
            vo2.setOrdId(StringUtils.trim(vo2.getOrdId()));
            vo2.setMaterialNo(StringUtils.trim(vo2.getMaterialNo()));
            vo2.setBatchNo(StringUtils.trim(vo2.getBatchNo()));
            vo2.setDate(StringUtils.trim(vo2.getDate()));
            ordList.add(vo2);

            op11Value.setOrdList(ordList);
            return op11Value;
        }
        if (node.getMachineCode().equals("OP12")){
            OP12 op12 = (OP12) cmdObject;
            OP12Value op12Value = new OP12Value();
            op12Value.setSequencer(op12.getSequencer());
            op12Value.setAlarm(op12.getAlarm());
            op12Value.setInHomePos(op12.getInHomePos());
            op12Value.setOperationMode(op12.getOperationMode());
            op12Value.setPartIdentifier(new String(op12.getPartIdentifier(), StandardCharsets.UTF_8));
            op12Value.setTypeNo(new String(op12.getTypeNo(), StandardCharsets.UTF_8));
            op12Value.setWpcId(new String(op12.getWpcId(), StandardCharsets.UTF_8));
            op12Value.setPartIdentifier(StringUtils.trim(op12Value.getPartIdentifier()));
            op12Value.setTypeNo(StringUtils.trim(op12Value.getTypeNo()));
            op12Value.setWpcId(StringUtils.trim(op12Value.getWpcId()));
            OP12Extend op12Extend = (OP12Extend)ordObj;
            List<BaseMaterialVO> ordList = new ArrayList<>();
            BaseMaterialVO vo1 = new BaseMaterialVO();
            vo1.setName("螺丝(M4)");
            vo1.setOrdId(new String(op12Extend.getScrewOrdId(), StandardCharsets.UTF_8));
            vo1.setMaterialNo(new String(op12Extend.getScrewMaterialNo(), StandardCharsets.UTF_8));
            vo1.setBatchNo(new String(op12Extend.getScrewBatchNo(), StandardCharsets.UTF_8));
            vo1.setDate(new String(op12Extend.getScrewDate(), StandardCharsets.UTF_8));
            vo1.setQuantity(op12Extend.getScrewQuantity());
            vo1.setOrdId(StringUtils.trim(vo1.getOrdId()));
            vo1.setMaterialNo(StringUtils.trim(vo1.getMaterialNo()));
            vo1.setBatchNo(StringUtils.trim(vo1.getBatchNo()));
            vo1.setDate(StringUtils.trim(vo1.getDate()));
            ordList.add(vo1);
            BaseMaterialVO vo2 = new BaseMaterialVO();
            vo2.setName("轧带");
            vo2.setOrdId(new String(op12Extend.getRibbonOrdId(), StandardCharsets.UTF_8));
            vo2.setMaterialNo(new String(op12Extend.getRibbonMaterialNo(), StandardCharsets.UTF_8));
            vo2.setBatchNo(new String(op12Extend.getRibbonBatchNo(), StandardCharsets.UTF_8));
            vo2.setDate(new String(op12Extend.getRibbonDate(), StandardCharsets.UTF_8));
            vo2.setQuantity(op12Extend.getRibbonQuantity());
            vo2.setOrdId(StringUtils.trim(vo2.getOrdId()));
            vo2.setMaterialNo(StringUtils.trim(vo2.getMaterialNo()));
            vo2.setBatchNo(StringUtils.trim(vo2.getBatchNo()));
            vo2.setDate(StringUtils.trim(vo2.getDate()));
            ordList.add(vo2);
            op12Value.setOrdList(ordList);
            return op12Value;
        }
        if (node.getMachineCode().equals("OP17")){
            OP17 op17 = (OP17) cmdObject;
            OP17Value op17Value = new OP17Value();
            op17Value.setSequencer(op17.getSequencer());
            op17Value.setAlarm(op17.getAlarm());
            op17Value.setInHomePos(op17.getInHomePos());
            op17Value.setOperationMode(op17.getOperationMode());
            op17Value.setPartIdentifier(new String(op17.getPartIdentifier(), StandardCharsets.UTF_8));
            op17Value.setTypeNo(new String(op17.getTypeNo(), StandardCharsets.UTF_8));
            op17Value.setWpcId(new String(op17.getWpcId(), StandardCharsets.UTF_8));
            op17Value.setPartIdentifier(StringUtils.trim(op17Value.getPartIdentifier()));
            op17Value.setTypeNo(StringUtils.trim(op17Value.getTypeNo()));
            op17Value.setWpcId(StringUtils.trim(op17Value.getWpcId()));
            OP17Extend op17Extend = (OP17Extend)ordObj;
            List<BaseMaterialVO> ordList = new ArrayList<>();
            BaseMaterialVO vo1 = new BaseMaterialVO();
            vo1.setName("螺丝(M5)");
            vo1.setOrdId(new String(op17Extend.getScrewM5OrdId(), StandardCharsets.UTF_8));
            vo1.setMaterialNo(new String(op17Extend.getScrewM5MaterialNo(), StandardCharsets.UTF_8));
            vo1.setBatchNo(new String(op17Extend.getScrewM5BatchNo(), StandardCharsets.UTF_8));
            vo1.setDate(new String(op17Extend.getScrewM5Date(), StandardCharsets.UTF_8));
            vo1.setQuantity(op17Extend.getScrewM5Quantity());
            vo1.setOrdId(StringUtils.trim(vo1.getOrdId()));
            vo1.setMaterialNo(StringUtils.trim(vo1.getMaterialNo()));
            vo1.setBatchNo(StringUtils.trim(vo1.getBatchNo()));
            vo1.setDate(StringUtils.trim(vo1.getDate()));
            ordList.add(vo1);
            BaseMaterialVO vo2 = new BaseMaterialVO();
            vo2.setName("螺丝(M6)");
            vo2.setOrdId(new String(op17Extend.getScrewM6OrdId(), StandardCharsets.UTF_8));
            vo2.setMaterialNo(new String(op17Extend.getScrewM6MaterialNo(), StandardCharsets.UTF_8));
            vo2.setBatchNo(new String(op17Extend.getScrewM6BatchNo(), StandardCharsets.UTF_8));
            vo2.setDate(new String(op17Extend.getScrewM6Date(), StandardCharsets.UTF_8));
            vo2.setQuantity(op17Extend.getScrewM6Quantity());
            vo2.setOrdId(StringUtils.trim(vo2.getOrdId()));
            vo2.setMaterialNo(StringUtils.trim(vo2.getMaterialNo()));
            vo2.setBatchNo(StringUtils.trim(vo2.getBatchNo()));
            vo2.setDate(StringUtils.trim(vo2.getDate()));
            ordList.add(vo2);
            op17Value.setOrdList(ordList);
            return op17Value;
        }
        if (node.getMachineCode().equals("OP19")){
            OP19 op19 = (OP19) cmdObject;
            OP19Value op19Value = new OP19Value();
            op19Value.setSequencer(op19.getSequencer());
            op19Value.setAlarm(op19.getAlarm());
            op19Value.setInHomePos(op19.getInHomePos());
            op19Value.setOperationMode(op19.getOperationMode());
            op19Value.setPartIdentifier(new String(op19.getPartIdentifier(), StandardCharsets.UTF_8));
            op19Value.setTypeNo(new String(op19.getTypeNo(), StandardCharsets.UTF_8));
            op19Value.setWpcId(new String(op19.getWpcId(), StandardCharsets.UTF_8));
            op19Value.setPartIdentifier(StringUtils.trim(op19Value.getPartIdentifier()));
            op19Value.setTypeNo(StringUtils.trim(op19Value.getTypeNo()));
            op19Value.setWpcId(StringUtils.trim(op19Value.getWpcId()));
            OP19Extend op19Extend = (OP19Extend)ordObj;
            List<BaseMaterialVO> ordList = new ArrayList<>();
            BaseMaterialVO vo1 = new BaseMaterialVO();
            vo1.setName("螺丝(M5)");
            vo1.setOrdId(new String(op19Extend.getScrewM5OrdId(), StandardCharsets.UTF_8));
            vo1.setMaterialNo(new String(op19Extend.getScrewM5MaterialNo(), StandardCharsets.UTF_8));
            vo1.setBatchNo(new String(op19Extend.getScrewM5BatchNo(), StandardCharsets.UTF_8));
            vo1.setDate(new String(op19Extend.getScrewM5Date(), StandardCharsets.UTF_8));
            vo1.setQuantity(op19Extend.getScrewM5Quantity());
            vo1.setOrdId(StringUtils.trim(vo1.getOrdId()));
            vo1.setMaterialNo(StringUtils.trim(vo1.getMaterialNo()));
            vo1.setBatchNo(StringUtils.trim(vo1.getBatchNo()));
            vo1.setDate(StringUtils.trim(vo1.getDate()));
            ordList.add(vo1);
            BaseMaterialVO vo2 = new BaseMaterialVO();
            vo2.setName("螺丝(M6)");
            vo2.setOrdId(new String(op19Extend.getScrewM6OrdId(), StandardCharsets.UTF_8));
            vo2.setMaterialNo(new String(op19Extend.getScrewM6MaterialNo(), StandardCharsets.UTF_8));
            vo2.setBatchNo(new String(op19Extend.getScrewM6BatchNo(), StandardCharsets.UTF_8));
            vo2.setDate(new String(op19Extend.getScrewM6Date(), StandardCharsets.UTF_8));
            vo2.setQuantity(op19Extend.getScrewM6Quantity());
            vo2.setOrdId(StringUtils.trim(vo2.getOrdId()));
            vo2.setMaterialNo(StringUtils.trim(vo2.getMaterialNo()));
            vo2.setBatchNo(StringUtils.trim(vo2.getBatchNo()));
            vo2.setDate(StringUtils.trim(vo2.getDate()));
            ordList.add(vo2);
            BaseMaterialVO vo3 = new BaseMaterialVO();
            vo3.setName("铜柱");
            vo3.setOrdId(new String(op19Extend.getCopperPillarOrdId(), StandardCharsets.UTF_8));
            vo3.setMaterialNo(new String(op19Extend.getCopperPillarMaterialNo(), StandardCharsets.UTF_8));
            vo3.setBatchNo(new String(op19Extend.getCopperPillarBatchNo(), StandardCharsets.UTF_8));
            vo3.setDate(new String(op19Extend.getCopperPillarDate(), StandardCharsets.UTF_8));
            vo3.setQuantity(op19Extend.getCopperPillarQuantity());
            vo3.setOrdId(StringUtils.trim(vo3.getOrdId()));
            vo3.setMaterialNo(StringUtils.trim(vo3.getMaterialNo()));
            vo3.setBatchNo(StringUtils.trim(vo3.getBatchNo()));
            vo3.setDate(StringUtils.trim(vo3.getDate()));
            ordList.add(vo3);
            BaseMaterialVO vo4 = new BaseMaterialVO();
            vo4.setName("铜排");
            vo4.setOrdId(new String(op19Extend.getCopperBarOrdId(), StandardCharsets.UTF_8));
            vo4.setMaterialNo(new String(op19Extend.getCopperBarMaterialNo(), StandardCharsets.UTF_8));
            vo4.setBatchNo(new String(op19Extend.getCopperBarBatchNo(), StandardCharsets.UTF_8));
            vo4.setDate(new String(op19Extend.getCopperBarDate(), StandardCharsets.UTF_8));
            vo4.setQuantity(op19Extend.getCopperBarQuantity());
            vo4.setOrdId(StringUtils.trim(vo4.getOrdId()));
            vo4.setMaterialNo(StringUtils.trim(vo4.getMaterialNo()));
            vo4.setBatchNo(StringUtils.trim(vo4.getBatchNo()));
            vo4.setDate(StringUtils.trim(vo4.getDate()));
            ordList.add(vo4);
            op19Value.setOrdList(ordList);
            return op19Value;
        }
        if (node.getMachineCode().equals("OP21")){
            OP21 op21 = (OP21) cmdObject;
            OP21Value op21Value = new OP21Value();
            op21Value.setSequencer(op21.getSequencer());
            op21Value.setAlarm(op21.getAlarm());
            op21Value.setInHomePos(op21.getInHomePos());
            op21Value.setOperationMode(op21.getOperationMode());
            op21Value.setPartIdentifier(new String(op21.getPartIdentifier(), StandardCharsets.UTF_8));
            op21Value.setTypeNo(new String(op21.getTypeNo(), StandardCharsets.UTF_8));
            op21Value.setWpcId(new String(op21.getWpcId(), StandardCharsets.UTF_8));
            op21Value.setPartIdentifier(StringUtils.trim(op21Value.getPartIdentifier()));
            op21Value.setTypeNo(StringUtils.trim(op21Value.getTypeNo()));
            op21Value.setWpcId(StringUtils.trim(op21Value.getWpcId()));
            OP21Extend op21Extend = (OP21Extend)ordObj;
            List<BaseMaterialVO> ordList = new ArrayList<>();
            BaseMaterialVO vo1 = new BaseMaterialVO();
            vo1.setName("螺丝(M4)");
            vo1.setOrdId(new String(op21Extend.getScrewOrdId(), StandardCharsets.UTF_8));
            vo1.setMaterialNo(new String(op21Extend.getScrewMaterialNo(), StandardCharsets.UTF_8));
            vo1.setBatchNo(new String(op21Extend.getScrewBatchNo(), StandardCharsets.UTF_8));
            vo1.setDate(new String(op21Extend.getScrewDate(), StandardCharsets.UTF_8));
            vo1.setQuantity(op21Extend.getScrewQuantity());
            vo1.setOrdId(StringUtils.trim(vo1.getOrdId()));
            vo1.setMaterialNo(StringUtils.trim(vo1.getMaterialNo()));
            vo1.setBatchNo(StringUtils.trim(vo1.getBatchNo()));
            vo1.setDate(StringUtils.trim(vo1.getDate()));
            ordList.add(vo1);
            op21Value.setOrdList(ordList);
            return op21Value;
        }
        if (node.getMachineCode().equals("OP23")){
            OP23 op23 = (OP23) cmdObject;
            OP23Value op23Value = new OP23Value();
            op23Value.setSequencer(op23.getSequencer());
            op23Value.setAlarm(op23.getAlarm());
            op23Value.setInHomePos(op23.getInHomePos());
            op23Value.setOperationMode(op23.getOperationMode());
            op23Value.setPartIdentifier(new String(op23.getPartIdentifier(), StandardCharsets.UTF_8));
            op23Value.setTypeNo(new String(op23.getTypeNo(), StandardCharsets.UTF_8));
            op23Value.setWpcId(new String(op23.getWpcId(), StandardCharsets.UTF_8));
            op23Value.setPartIdentifier(StringUtils.trim(op23Value.getPartIdentifier()));
            op23Value.setTypeNo(StringUtils.trim(op23Value.getTypeNo()));
            op23Value.setWpcId(StringUtils.trim(op23Value.getWpcId()));
            OP23Extend op23Extend = (OP23Extend)ordObj;
            List<BaseMaterialVO> ordList = new ArrayList<>();
            BaseMaterialVO vo1 = new BaseMaterialVO();
            vo1.setName("螺丝(M3)");
            vo1.setOrdId(new String(op23Extend.getScrewOrdId(), StandardCharsets.UTF_8));
            vo1.setMaterialNo(new String(op23Extend.getScrewMaterialNo(), StandardCharsets.UTF_8));
            vo1.setBatchNo(new String(op23Extend.getScrewBatchNo(), StandardCharsets.UTF_8));
            vo1.setDate(new String(op23Extend.getScrewDate(), StandardCharsets.UTF_8));
            vo1.setQuantity(op23Extend.getScrewQuantity());
            vo1.setOrdId(StringUtils.trim(vo1.getOrdId()));
            vo1.setMaterialNo(StringUtils.trim(vo1.getMaterialNo()));
            vo1.setBatchNo(StringUtils.trim(vo1.getBatchNo()));
            vo1.setDate(StringUtils.trim(vo1.getDate()));
            ordList.add(vo1);
            op23Value.setOrdList(ordList);
            return op23Value;
        }
        if (node.getMachineCode().equals("OP27")){
            OP27 op27 = (OP27)cmdObject;
            OP27Value op27Value = new OP27Value();
            op27Value.setSequencer(op27.getSequencer());
            op27Value.setAlarm(op27.getAlarm());
            op27Value.setInHomePos(op27.getInHomePos());
            op27Value.setOperationMode(op27.getOperationMode());
            op27Value.setPartIdentifier(new String (op27.getPartIdentifier(), StandardCharsets.UTF_8));
            op27Value.setTypeNo(new String (op27.getTypeNo(), StandardCharsets.UTF_8));
            op27Value.setWpcId(new String (op27.getWpcId(), StandardCharsets.UTF_8));
            op27Value.setPartIdentifier(StringUtils.trim(op27Value.getPartIdentifier()));
            op27Value.setTypeNo(StringUtils.trim(op27Value.getTypeNo()));
            op27Value.setWpcId(StringUtils.trim(op27Value.getWpcId()));
            return op27Value;
        }
        return null;
    }
}
